#include<iostream>
#include<vector>
#include<queue>
#include<cstring>
#include<cmath>
#include<map>
#include<set>
#include<cstdio>
#include<algorithm>
#define debug(a) cout<<#a<<"="<<a<<endl;
using namespace std;
const int maxn=1e5+100;
typedef long long LL;
inline LL read(){LL x=0,f=1;char ch=getchar();	while (!isdigit(ch)){if (ch=='-') f=-1;ch=getchar();}while (isdigit(ch)){x=x*10+ch-48;ch=getchar();}
return x*f;}
double a[maxn],b[maxn];
LL tot1=0,tot2=0;
bool cmp(LL A,LL B){
    return A>B;
}
int main(void)
{

  LL t;t=read();
  while(t--){
    LL n;n=read();
    tot1=tot2=0;
    for(LL i=0;i<=n;i++) a[i]=b[i]=0;
    for(LL i=1;i<=2*n;i++){
        LL x,y;x=read();y=read();
        if(x==0){
            a[++tot1]=1.0*y*y;
        }
        else if(y==0){
            b[++tot2]=1.0*x*x;
        }
    }
    sort(a+1,a+1+tot1);
    sort(b+1,b+1+tot2);
    double sum1=0;
    for(LL i=1;i<=tot1;i++){
        sum1+=sqrt(1.0*a[i]+1.*b[i]);
    }
    printf("%.12f\n",sum1);
  }
return 0;
}
